package com.homework;

import java.io.File;
import java.util.Scanner;

/**
 * @author xiyu
 * @version 1.0
 * @date 2025/3/28 18:05
 * @description
 */
public class T4 {
    public static void main(String[] args) {
//        File dir = new File("D:\\file\\test");
        Scanner input = new Scanner(System.in);
        System.out.println("请输入文件夹路径：");
        String Path = input.nextLine();
        File dir = new File(Path);
        File[] files = dir.listFiles();
        for (File file : files) {
            System.out.println(file.getName());
            ifdir(file,0);
        }
    }

    public static void ifdir(File file,int level) {
        if (file.isDirectory()){
            level++;
            File file1 = new File(file.getAbsolutePath());
            File[] files1 = file1.listFiles();
            for (File file2 : files1) {
                for (int i = 0; i < level; i++) {
                    System.out.print("\t");
                }
                System.out.println(file2.getName());
                ifdir(file2,level);
            }
        }
    }
}
